﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace ElingOA6_Admin_DSJCJ.BLL
{
    public class Leave
    {
        private readonly ElingOA6_Admin_DSJCJ.DAL.Leave dal = new ElingOA6_Admin_DSJCJ.DAL.Leave();
        public Leave()
        { }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public decimal Add(ElingOA6_Admin_DSJCJ.Model.Leave model)
        {
            return dal.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(ElingOA6_Admin_DSJCJ.Model.Leave model)
        {
            return dal.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(decimal FLeaveID)
        {

            return dal.Delete(FLeaveID);
        }
        
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool LeaveOut(ElingOA6_Admin_DSJCJ.Model.Leave model)
        {
            return dal.LeaveOut(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool DeleteList(string FLeaveIDlist)
        {
            return dal.DeleteList(FLeaveIDlist);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ElingOA6_Admin_DSJCJ.Model.Leave GetModel(decimal FLeaveID)
        {

            return dal.GetModel(FLeaveID);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<ElingOA6_Admin_DSJCJ.Model.Leave> DataTableToList(DataTable dt)
        {
            List<ElingOA6_Admin_DSJCJ.Model.Leave> modelList = new List<ElingOA6_Admin_DSJCJ.Model.Leave>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                ElingOA6_Admin_DSJCJ.Model.Leave model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = dal.DataRowToModel(dt.Rows[n]);
                    if (model != null)
                    {
                        modelList.Add(model);
                    }
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<ElingOA6_Admin_DSJCJ.Model.Leave> VDataTableToList(DataTable dt)
        {
            List<ElingOA6_Admin_DSJCJ.Model.Leave> modelList = new List<ElingOA6_Admin_DSJCJ.Model.Leave>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                ElingOA6_Admin_DSJCJ.Model.Leave model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = dal.VDataRowToModel(dt.Rows[n]);
                    if (model != null)
                    {
                        modelList.Add(model);
                    }
                }
            }
            return modelList;
        }
        
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<ElingOA6_Admin_DSJCJ.Model.Leave> GetLeaveStatisticsList(string begindate, string enddate)
        {
            DataSet ds = dal.GetLeaveStatisticsList(begindate,enddate);
            return VDataTableToList(ds.Tables[0]);
        }
         /// <summary>
        /// 需要参与去向管理的人员名单
        /// </summary>
        /// <param name="entityNo">公司编号</param>
        /// <returns></returns>
        public DataTable GetListByEntityNo(string entityNo)
        {
            return dal.GetListByEntityNo(entityNo).Tables[0];
        }
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="emplModelList"></param>
        public void UpdataEmpl(List<Model.HREmpl> emplModelList)
        {
            dal.UpdataEmpl(emplModelList);
        }

        /// <summary>
        /// 审核外出登记
        /// <creator>sunlj</creator>
        /// <date>2014-05-22</date>
        /// </summary>
        /// <param name="LeaveModel"></param>
        public void AuditLeave(Model.Leave LeaveModel)
        {
            dal.AuditLeave(LeaveModel);
        }

    }
}
